﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 输出参数01
{
    class Program
    {
        static void Main(string[] args)
        {
            MyMath mm = new MyMath();
            int aa = 12;
            int bb = 34;
            int xx, yy;
            mm.Cal(aa, bb, out xx, out yy);
            Console.WriteLine("xx = " + xx + "; yy = " + yy);   // xx = -22; yy = 46
        }
    }

    class MyMath
    {
        // ref关键字修饰的变量在传递之前必须赋值，out关键字修饰的参数传递之前可以不赋值，但是在离开方法前必须要对参数赋值
        // 这也是有它们所代表的功能决定的
        public void Cal(int a, int b, out int x, out int y)
        {
            x = a - b;
            y = a + b;
        }
    }
}
